
<template>
  <div>
        <Card>
            <div slot="title" >
                <Button v-if="btnp.yjxying_fqyjsj" @click="handleClickAddForm" class="zh-hollow" type="primary" icon="plus-round">发起应急事件</Button>
            </div>
            <Form :model="formItem" :label-width="70">
                <Row :gutter="10" type="flex"  align="middle"  >
                    <Col span="8">
                        <FormItem label="应急事件">
                            <Input v-model="formItem.key" placeholder="编号/标题" clearable></Input>
                        </FormItem>
                    </Col>
                    <Col span="8" v-if="user_type!=='01'">
                        <FormItem label="客户">
                            <Select v-model="formItem.customer_uuid" filterable @on-change="searchCustomerChange">
                                <Option  v-for="item in moreCustomerList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem label="机构">
                            <Input @on-focus="s_tree=true;" :disabled="!formItem.customer_uuid||formItem.customer_uuid=='全部'" v-model="formItem.instName" placeholder="请选择机构" readonly></Input>
                            <!-- <Select v-model="formItem.inst_uuid" :disabled="formItem.customer_uuid.length<=0" filterable>
                                <Option  v-for="item in moreMechanismList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
                            </Select> -->
                        </FormItem>
                    </Col>
                <!-- </Row>
                <Row :gutter="10" type="flex" justify="space-between" align="middle"  > -->
                    <Col span="8">
                        <FormItem label="进度">
                            <Select v-model="formItem.status" >
                                <Option  v-for="item in progressList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="12">
                        <FormItem label="发起时间">
                            <DatePicker v-model="timeRange" format="yyyy-MM-dd HH:mm" type="datetimerange" placement="bottom-end" placeholder="请选择开始和结束时间"></DatePicker>
                        </FormItem>
                    </Col>
                </Row>
                <Row  >
                    <Col span="8" offset="16"  style="text-align:right;">
                        <Button @click="handleClickgetTable" class="zh-hollow" type="primary" icon="ios-search-strong">搜索</Button>
                    </Col> 
                </Row>
            </Form>
        </Card>
        <Card style="margin-top:10px;" :padding="0">
            <Table :loading="loading" border :columns="columns" :data="data"></Table>
            <Page  :total="total" show-total show-sizer :current.sync="formItem.pageNumber" @on-change="pageChange" @on-page-size-change="pageSizeChange"></Page>
        </Card>
    <!-- 发起应急事件 -->
    <Modal title="发起应急事件" :loading="saveLoading" v-model="modal_add_emergency_form" @on-ok="save" ok-text="保存" cancel-text="放弃操作" :mask-closable="false"  class-name="vertical-center-modal">
      <Form :model="addForm" :label-width="80" style="padding:20px;">
        <FormItem label="发起客户" v-if="user_type!='01'">
            <Select v-model="addForm.customer_uuid" filterable @on-change="formCustomerChange">
                <Option  v-for="item in customerList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="发起机构">
            <Input @on-focus="f_tree=true;" :disabled="addForm.customer_uuid.length<=0" v-model="addForm.instname" placeholder="请选择机构" readonly></Input>
            <!-- <Select v-model="addForm.inspection_uuid" filterable :disabled="addForm.customer_uuid.length<=0">
                <Option  v-for="item in mechanismList" :value="item.uuid" :key="item.uuid">{{ item.name }}</Option>
            </Select> -->
        </FormItem>
        <FormItem label="事件标题">
          <Input v-model="addForm.title" :maxlength="20"></Input>
        </FormItem>
        <FormItem label="事件描述">
            <Input type="textarea" :autosize="{minRows: 2,maxRows: 5}" :maxlength="200" v-model="addForm.content" ></Input>
        </FormItem>
        <FormItem label="发送到分组">
            <Select v-if="!!groupList&&groupList.length>0" v-model="addForm.group_uuid" :disbaled="addForm.customer_uuid.length<=0">
                <Option  v-for="item in groupList" :value="item.uuid" :key="item.uuid">{{ item.title }}</Option>
            </Select>
            <template v-else>
                <Button v-if="addForm.customer_uuid.length>0&&addForm.title!=''" @click="modal_transfer=true"   class="zh-hollow" type="primary" icon="plus-round">添加分组</Button>
                <p v-else>请先输入客户和标题</p>
            </template>
            
        </FormItem>

      </Form>
    </Modal>
    <Modal title="应急事件详情" width="450" v-model="modal_mergency_details" class=" no_footer_modal" class-name="vertical-center-modal">
        <!-- <p slot="header" >应急事件详情</p> -->
        <Form :label-width="100" style="padding:20px;">
            <FormItem label="客户：">{{emergency_details.customer}}</FormItem>
            <FormItem label="机构：">{{emergency_details.mechanism}}</FormItem>
            <FormItem label="发起时间：">{{emergency_details.time}}</FormItem>
            <FormItem label="事件标题：">{{emergency_details.title}}</FormItem>
            <FormItem label="事件描述：">{{emergency_details.description}}</FormItem>
            <FormItem label="可见人员：">{{emergency_details.personnel}}</FormItem>
            <FormItem label="关闭时间：">{{emergency_details.close}}</FormItem>                                                
        </Form>
    </Modal>
    <Modal :title="stateModaltitle" :loading='changeLoading'  v-model="modal_state_change" @on-ok='chageStatus' ok-text="保存" cancel-text="放弃操作"  class-name="vertical-center-modal">
        <Form :model="stateForm" :label-width="100" style="padding:20px;">
            <FormItem label="更新状态为*">
                <Select v-model="stateForm.status" >
                    <Option  v-for="item in stateList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                </Select>
            </FormItem>
            <FormItem label="更新说明*">
                <Input type="textarea" :maxlength="200" :autosize="{minRows: 2,maxRows: 5}" v-model="stateForm.content" ></Input>
            </FormItem>
        </Form>
    </Modal>
    <Modal title="应急事件讨论" v-model="modal_discuss" class=" no_footer_modal" >
        <div class="detail-other zh-flex zh-flex-3" >
            <div class="detail-other-item" style="width:100%;paddingLeft:90px;" v-for="(item,index) in discuss_detail_people" :key="index">
                <label>{{item.proportion}}：</label>
                <span style="color:#2d8cf0">{{item.personnel1}}</span>
                <span v-if="!!item.personnel2&&!!item.personnel2">,</span>
                <span>{{item.personnel2}}</span>
            </div>
            <!-- <div class="detail-other-item" style="width:100%;paddingLeft:90px;">
                <label>{{discuss_detail.noSignIn.proportion}}：</label>
                <span style="color:#2d8cf0">{{discuss_detail.noSignIn.personnel1}}</span>
                <span v-if="discuss_detail.noSignIn.personnel2">,</span>
                <span>{{discuss_detail.noSignIn.personnel2}}</span>
            </div> -->
        </div>
        <div style="padding:15px 40px;" v-if="!!discuss_detail_talk&&discuss_detail_talk.length>0">
            <template v-for="(item,index) in discuss_detail_talk" >
                <Card v-if="item.user_type==='00'||item.user_type==null" :key="index" style="background:#2d8cf0;">
                    <p style="color:#dedede;">{{item.time}}</p>
                    <p style="textAlign:center;color:#fff;">{{item.content}}</p>
                </Card>
                <div v-else :key="index" class="detail-supplement-item">
                    <div class="spokesman">
                        <Avatar icon="person" size="large" :src="item.headImg?domain+item.headImg:''" />
                        <div style="marginLeft:10px;">
                        <p>{{item.user_nick}}</p>
                        <p style="color:#dedede;">{{item.time}}</p>
                        </div>
                    </div>
                    <p v-if="item.user_type==='01'" class="speech" style="color:#2d8cf0">{{item.content}}</p>
                    <p v-if="item.user_type==='02'" class="speech" >{{item.content}}</p>
                    <div v-if="item.imageList.length>0" class="wrap">
					    <img v-for="(src,i) in item.imageList"  :key="i" :src="domain+src" @click="handleClickPicLook(src)" alt="">
                    </div>
                    <div v-if="!!item.video" class="wrap">
                        <video poster="" @click="handleClickVideoPlay(item.video)"  :src="item.video"></video>
                    </div>
                </div>
            </template>
        </div>
    </Modal>
    <Modal title="选择人员" :loading="grouploading" width="656" @on-ok="chosepeo" :mask-closable="false" ok-text="确定" v-model="modal_transfer"  cancel-text="放弃操作"  class-name="vertical-center-modal">
        <Transfer
            :data="transferList"
            :target-keys="targetKeys"
            :render-format="transRender"
            :list-style="transferListStyle"
            @on-change="handleTransferChange"
            :titles="transferTitles"
            filterable
        ></Transfer>
    </Modal>  
    <Modal title="查看图片" v-model="look_pic_wrap.look_pic" class="no_footer_modal">
			<img style="width:100%;" :src="domain+look_pic_wrap.src" alt="">
		</Modal>
		<!-- 看视频 -->
		<Modal title="查看视频" v-model="look_video_wrap.look_video" class="no_footer_modal">
			<video style="width:100%;" :src="domain+look_video_wrap.src" controls alt=""></video>
		</Modal> 
        <Modal title="选择机构" v-model="s_tree" @on-ok="confirmST" :mask-closable="false" >
			<div style="padding:15px 30px;">
				<Tree :data="s_tree_data"   @on-select-change="s_selectChange"></Tree>
			</div>
		</Modal>  
        <Modal title="选择机构" v-model="f_tree" :loading="ft_load" @on-ok="confirmF" :mask-closable="false" >
			<div style="padding:15px 30px;">
				<Tree :data="f_tree_data"   @on-select-change="f_selectChange"></Tree>
			</div>
		</Modal>   
  </div>
</template>

<script>
import util from '@/libs/util'
import {getBankOrg,getEmResTable,getAllPeoByCusUuid,getUrgGroupList,getEventDetail,getDiscuss,getDiscussCon,getOrgTree} from '@/libs/get'
import {changeUgStatus,saveEmerGroup,saveurgent} from '@/libs/post'
export default {
    name:'emergencResponse',
    data () {
        return {
            ft_load:true,
			f_select_op:[],
			f_tree_data:[],
			f_tree:false,
            s_select_op:[],
			s_tree_data:[],
			s_tree:false,
            /**看视频 */
            look_video_wrap:{
                look_video:false,
                src:''
            },
            /** 查看图片*/
            look_pic_wrap:{
                look_pic:false,
                src:''
            },
            domain:this.$store.state.app.domain,
            grouploading:true,
            saveLoading:true,
            changeLoading:true,
            userUuid:'',
            user_type:'',
            btnp:{},
            btn:{
                yjxying_fqyjsj:false,
                yjxying_xq:false,
                yjxying_tl:false,
                yjxying_gxzt:false,
                yjxying_cxdk:false
            },
            transferTitles:['可选','已选中'],
            transferListStyle: {
                width: '300px',
                margin:'0 auto'
                
            },
            transferList:[],
            targetKeys:[],
            modal_transfer:false,
            discuss_detail_people:[],
            discuss_detail_talk:[],
            // discuss_detail:{
            //    signIn:{
            //       proportion:'' ,
            //       personnel:''
            //    },
            //    noSignIn:{
            //       proportion:'' ,
            //       personnel:''
            //    },
            //    talk:[]
            // },
            modal_discuss:false,
            stateForm:{
                uuid:'',
                status:1,
                content:''
            },
            stateModaltitle:'',
            modal_state_change:false,
            addForm:{
                customer_uuid:'',
                inspection_uuid:'',
                instname:'',
                title:'',
                content:'',
                group_uuid:''              
            },
            modal_mergency_details:false,
            emergency_details:{
                customer:'',
                mechanism:'',
                time:'',
                title:'',
                description:'',
                personnel:'',
                close:''
            },
            loading:true,
            total:150,
            modal_add_emergency_form:false,
            timeRange:[],
            formItem:{
                key:'',
                customer_uuid:'全部',
                inst_uuid:'全部',
                instName:'',
                status:'全部',
                pageNumber:1,
                pageSize:10
            },
            moreCustomerList:[],
            customerList:[],
            moreMechanismList:[],
            mechanismList:[],
            stateList:[],
            progressList:[
                {
                    value:'全部',
                    label:'全部'
                },
                {
                    value:'1',
                    label:'进行中'
                },{
                    value:'2',
                    label:'已关闭'
                }
            ],
            groupList:[],
            columns:[
                {
                    key:'number',
                    title:'应急编号',
                    fixed:'left',
                    minWidth:150
                },
                {
                    key:'title',
                    title:'事件标题',
                    minWidth:150
                },
                {
                    key:'partner_uuid',
                    title:'客户',
                    minWidth:120
                },
                {
                    key:'inspection_name',
                    title:'机构',
                    minWidth:120
                },
                {
                    key:'created',
                    title:'发起时间',
                    align:'center',
                    minWidth:150
                },
                {
                    key:'statusStr',
                    title:'进度',
                    align:'center',
                    minWidth:80
                },
                {
                    key:'action',
                    title:'操作',
                    align:'center',
                    minWidth:200,
                    fixed:'right',
                    render:(h,params)=>{
                        //判断是否显示某些操作按钮
                        let uuid=params.row.uuid;
                        let status=params.row.status;
                        return h('div',[
                        h('Button',{
                            props:{
                            type:'text',
                            size:'small'
                            },
                            style:{
                            color:'#2D8CF0',
                            display:this.btnp.yjxying_xq?'inline-block':'none'
                            },
                            on:{
                                click:()=>{
                                    this.getDetails(uuid);
                                   this.modal_mergency_details=true; 

                                }
                            }
                        },'详情'),
                        h('Button',{
                            props:{
                            type:'text',
                            size:'small'
                            },
                            style:{
                            color:'#2D8CF0',
                            display:this.btnp.yjxying_tl?status!='2'?'inline-block':'none':'none'
                            },
                            on:{
                            click:()=>{
                                this.modal_discuss=true;
                                this.getDiscussDetail(uuid);
                            }
                            }
                        },'讨论'),
                        h('Button',{
                            props:{
                            type:'text',
                            size:'small'
                            },
                            style:{
                            color:'#2D8CF0',
                            display:this.btnp.yjxying_gxzt?status=='1'?'inline-block':'none':'none'
                            },
                            on:{
                            click:()=>{
                                this.stateModaltitle='更新状态';
                                this.modal_state_change=true;
                                this.stateForm.uuid=uuid;
                            }
                            }
                        },'更新状态'),
                        h('Button',{
                            props:{
                            type:'text',
                            size:'small'
                            },
                            style:{
                            color:'#2D8CF0',
                            display:this.btnp.yjxying_cxdk?status=='2'?'inline-block':'none':'none'
                            },
                            on:{
                            click:()=>{
                                this.stateModaltitle='重新打开';
                                this.modal_state_change=true;
                                this.stateForm.uuid=uuid;
                            }
                            }
                        },'重新打开'),
                        ])
                    }
                }
                
            ],
            data:[]
        };
    },
    methods:{
        init(){
            let that=this;
            util.isCustomer(this);
            let timer;
			if(that.user_type!=='01'){
				timer=setInterval(()=>{
					if(that.$store.state.user.customer.length>0){
						that.moreCustomerList=[{name:'全部',uuid:'全部'},...that.$store.state.user.customer];
                        that.customerList=that.$store.state.user.customer;
						clearInterval(timer)	
					}
				},500);
			}else{
                this.searchCustomerChange(this.userUuid);
				//this.newSearchCustomerChange(this.userUuid,'search');
                //this.newSearchCustomerChange(this.userUuid,'form');
                this.getFormInstTree(this.userUuid);
                this.getStaff(this.userUuid);
                this.getGroupList(this.userUuid)
			}
			// setTimeout(()=>{
			// 	if(this.user_type=='00'){
            //         that.moreCustomerList=[{name:'全部',uuid:'全部'},...that.$store.state.user.customer];
            //         that.customerList=that.$store.state.user.customer;
			// 	}
			// },5000);
			// if(this.user_type=='01'){
            //     this.newSearchCustomerChange(this.userUuid,'search');
            //     this.newSearchCustomerChange(this.userUuid,'form');
            //     this.getStaff(this.userUuid);
            //     this.getGroupList(this.userUuid)
				
			// }
        },
        async getFormInstTree(value,p,c,d){
			this.addForm.inspection_uuid='';
			this.addForm.instname='';
			this.f_select_op=[];
			if(value!==''){
				let res=await getOrgTree(value,p,c,d);
				let response=res.data;
				if(response.code===200){
					this.f_tree_data=util.tree([response.data]);
				}else{
					this.$Notice.error({
						title: '获取机构失败',
						desc:response.msg
					});
				}
			}
		},
		f_selectChange(selectarr){
			this.f_select_op=selectarr;
		},
		confirmF(){
			if(this.f_select_op.length>0){
				if(this.f_select_op[0].canChoose=='true'){
					this.addForm.inspection_uuid=this.f_select_op[0].value;
					this.addForm.instname=this.f_select_op[0].title;
				}else{
					this.$Notice.error({
						desc:'请选择有效节点'
					});
					this.ft_load=false;
					let that=this;
					setTimeout(() => {
						that.ft_load=true;
					}, 200);
					return false
				}
				
			}else{
				this.addForm.inspection_uuid='';
				this.addForm.instname='';
			}
			this.f_tree=false;
		},
        async getSearchInstTree(value){
            this.formItem.inst_uuid='';
            this.formItem.instName='';
            this.s_select_op=[];
			if(value!=='全部'){
				let res=await getOrgTree(value);
				let response=res.data;
				if(response.code===200){
					this.s_tree_data=util.tree([response.data]);
				}else{
					this.$Notice.error({
						title: '获取机构失败',
						desc:response.msg
					});
				}
			}
		},
		s_selectChange(selectarr){
			this.s_select_op=selectarr;
		},
		confirmST(){
			if(this.s_select_op.length>0){
				this.formItem.inst_uuid=this.s_select_op[0].value;
				this.formItem.instName=this.s_select_op[0].title;
			}else{
				this.formItem.inst_uuid='';
				this.formItem.instName='';
			}
		},
        handleClickVideoPlay(src){
			this.look_video_wrap.look_video=true;
			this.look_video_wrap.src=src;
		},
		handleClickPicLook(src){
			this.look_pic_wrap.look_pic=true;
			this.look_pic_wrap.src=src;
		},
        async chosepeo(){
            if(this.targetKeys.length<=0){
                this.$Notice.error({
                    desc:"请选择人员"
                })
            }else{
                let member_uuids=this.targetKeys.join(',');
                let customer_uuid=this.addForm.customer_uuid;
                let name=this.addForm.title;
                let res=await saveEmerGroup({member_uuids,customer_uuid,name});
                let response=res.data;
                if(response.code==200){
                    this.$Notice.success({
                        desc:'已保存'
                    });
                    this.getGroupList(customer_uuid);
                    this.modal_transfer=false;
                    this.targetKeys=[];
                }else{
                    this.$Notice.error({
                        desc:response.msg
                    })
                }
            }
            let that=this;
            this.grouploading=false;
            setTimeout(() => {
                that.grouploading=true;
            }, 500);
            
        },
        async getDiscussDetail(uuid){
            let res=await getDiscuss(uuid);
            let res2=await getDiscussCon(uuid);
            let response=res.data;
            let response2=res2.data;
            if(response.code===200&&response2.code===200){
                let obj=response.data;
                
                this.discuss_detail_people=obj.userList.map(item=>{
                    let a={};
                    a.proportion=item.checkedNum;
                    a.personnel1=item.userNames.split(',').filter(item=>{
                        if(item.startsWith('01')){
                            return item
                        }
                    }).map(item=>{return item.slice(2)}).join(',');
                    a.personnel2=item.userNames.split(',').filter(item=>{
                        if(item.startsWith('02')){
                            return item
                        }
                    }).map(item=>{return item.slice(2)}).join(',');
                    return a
                });
                this.discuss_detail_talk=response2.data.map(item=>{
                        item.time=item.created.slice(0,16);
                        item.imageList=!!item.image?item.image.split(','):[];
                        item.headImg='';
                        return item
                    });
            }else{
                this.$Notice.error({
                    desc:response.msg
                });
            }
        },
        async getDetails(uuid){
            let res=await getEventDetail(uuid);
            let response=res.data;
            if(response.code===200){
                let obj=response.data;
                this.emergency_details={
                    customer:obj.partner_name,
                    mechanism:obj.inspection_name,
                    time:obj.created.slice(0,16),
                    title:obj.title,
                    description:obj.content,
                    personnel:obj.groups,
                    close:!!obj.closed_time?obj.closed_time.slice(0,16):''
                }
            }else{
                this.$Notice.error({
                    desc:response.msg
                });
            }
        },
        async getGroupList(uuid){
            let res=await getUrgGroupList(uuid);
            let response=res.data;
            if(response.code===200){
                this.groupList=response.data;
            }else{
                this.$Notice.error({
                    desc:response.msg
                });
            }
        },
        async getStaff(uuid){
            let res=await getAllPeoByCusUuid(uuid);
            let response=res.data;
            if(response.code===200){
                this.transferList=response.data.map(item=>{
                    item.key=item.uuid
                    return item
                })
                
            }else{
                this.$Notice.error({
                    desc:response.msg
                });
            }
        },
        searchCustomerChange(value){
            this.getSearchInstTree(value);
			//this.newSearchCustomerChange(value,'search')
        },
        async formCustomerChange(value){
            await this.getFormInstTree(value);
            //await this.newSearchCustomerChange(value,'form');
            let uuids=this.mechanismList.map(item=>{
                return item.uuid
            });
            if(!uuids.includes(this.addForm.inspection_uuid)){
                this.addForm.inspection_uuid=''
            }
            await this.getGroupList(value);
            if(this.groupList.length<=0){
                this.getStaff(value)
            }
        },
		// async newSearchCustomerChange(value,type){
		// 	if(value!=='全部'){
		// 	let res =await getBankOrg(value,'','','')
		// 	if(res.status===200){
		// 		let response=res.data;
		// 		if(response.code===200){
        //             if(type==='search'){
        //                 this.moreMechanismList=[{uuid:'全部',name:'全部'},...response.data]
        //             }else if(type==='form'){
        //                 this.mechanismList=response.data
        //             }
		// 		}else{
		// 			this.$Notice.error({
		// 				title: '请求出错',
		// 				desc:response.msg
		// 			});
		// 		}
		// 	}else{
		// 		this.$Notice.error({
		// 			title: '请求失败'
		// 		});
		// 	} 
		// 	}else{
		// 	this.formItem.inspection_uuid='';
		// 	}
        // },
        pageSizeChange(size){
			//回到第一页
			this.formItem.pageNumber=1;
			this.formItem.pageSize=size;
			this.getTable();
		},
		pageChange(number){
			this.formItem.pageNumber=number;
			this.getTable();
		},
		handleClickgetTable(){
			this.formItem.pageNumber=1;
			this.getTable();
		},
		async getTable(){
			this.loading=true;
			let form=JSON.parse(JSON.stringify(this.formItem));
			for(let key in form){
				if(form[key]==='全部'){
				    form[key]='';
				}
            }
			if(!!this.timeRange[0]&&this.timeRange.length>0){
				form.startTime=util.time1(this.timeRange[0]);
				form.endTime=util.time1(this.timeRange[1]);
			}
			let res=await getEmResTable(form);
			if(res.status===200){
				let response=res.data;
				if(response.code===200){
					this.total=response.data.totalRow;
					this.data=response.data.list;
					this.loading=false;
				}else{
					this.$Notice.error({
						desc:response.msg
					});
				}
			}else{
				this.$Notice.error({
					title: '请求失败'
				});
			} 
        },
        async chageStatus(){
            if(this.stateForm.content==''){
                this.$Notice.error({
                    desc:'更新说明不能为空'
                })
            }else{
                let form =JSON.parse(JSON.stringify(this.stateForm));
                let res=await changeUgStatus(form);
                let response=res.data;
                if(response.code==200){
                    this.$Notice.success({
                        desc:'已更新'
                    });
                    this.modal_state_change=false;
                    this.getTable();
                }else{
                    this.$Notice.error({
                        desc:response.msg
                    })
                }
            }
            this.changeLoading=false;
            let that=this;
            setTimeout(() => {
                that.changeLoading=true;
            }, 500);
        },
        async save(){
            if(this.user_type!='01'&&this.addForm.customer_uuid.length<=0){
                this.$Notice.error({
                    desc:'请选择发起客户'
                })
            }else if(this.addForm.inspection_uuid.length<=0){
                this.$Notice.error({
                    desc:'请选择发起机构'
                })
            }else if(this.addForm.title==''){
                this.$Notice.error({
                    desc:'请输入应急事件标题'
                })
            }else if(this.addForm.content==''){
                this.$Notice.error({
                    desc:'请描述应急事件'
                })
            }else if(this.addForm.group_uuid.length<=0){
                this.$Notice.error({
                    desc:'请选择报修客戶'
                })
            }else{
                let form =JSON.parse(JSON.stringify(this.addForm));
                let res=await saveurgent(form);
                let response=res.data;
                if(response.code==200){
                    this.$Notice.success({
                        desc:'已保存'
                    });
                    this.getTable();
                    this.modal_add_emergency_form=false;
                }else{
                    this.$Notice.error({
                        desc:response.msg
                    })
                }
            }
            this.saveLoading=false;
            let that=this;
            setTimeout(() => {
                that.saveLoading=true;
            }, 500);
        },
        handleClickAddForm(){
            this.modal_add_emergency_form=true;
        },
        transRender(item){
            return `${item.name}(${item.mobile})---${item.instName}`
        },
        handleTransferChange(newTargetKeys){
            this.targetKeys=newTargetKeys
        }
    },
    watch:{
        modal_state_change:function(){
            if(!this.modal_state_change){
                this.stateForm={
                    uuid:'',
                    status:1,
                    content:''
                }
            }
        },
        stateModaltitle:function(){
            if(this.stateModaltitle=='更新状态'){
                this.stateList=[
                    {
                        value:'1',
                        label:'进行中'
                    },{
                        value:'2',
                        label:'已关闭'
                    }
                ]
            }else{
                this.stateList=[
                    {
                        value:'1',
                        label:'进行中'
                    }
                ]
            }
        }
    },
    created(){
        this.init();
        this.btnp=util.bpower(this,this.btn);
        this.getTable();
    }
}

</script>
<style lang='scss' scope >
.wrap{
		display:flex;
		flex-wrap: wrap;
		justify-content: space-between;
		align-items: center;
		
		img,video{
			width:100px;
			height:100px;
			margin-bottom:10px;
			cursor: pointer;
            }}
.ivu-date-picker{
  width:100%;
}
  .detail-supplement-item{
    padding:6px 0;
    border-bottom:1px solid #eee;
    .spokesman{
      display: flex;
      align-items: center;
      margin-bottom:5px;
    }
    .speech{
      padding-left:50px;
      padding-right:20px;
    }
  }

</style>